<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>发布班次</title>
    <%@ include file="/WEB-INF/include/commoncss.jsp"%>
    <script type="text/javascript"
            src="${ctx}/javascript/laydate/laydate.js"></script>
</head>
<body>
<article class="page-container">
    <div action="" class="form form-horizontal" id="scheduleAdd">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>中文名：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input id="nation_z" name="nation_z" value="" class="input-text"/>
            </div>
            <label class="form-label col-xs-4 col-sm-2">英文名：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input id="nation_e" name="nation_e" value="" class="input-text" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>所属大陆：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <span class="select-box">
                    <select class="select" id="continent" name="continent">
                        <c:forEach items="${clist}" var="c">
                            <option value="${c.continent_id}" <c:if test="${c.continent_id eq nationinfo.continent}">select</c:if> >${c.continent_name}</option>
                        </c:forEach>
                    </select>
                </span>
            </div>
            <label class="form-label col-xs-4 col-sm-2">建国时间：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input id="establish_time" name="establish_time" value="" class="input-text laydate-icon"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">首都：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input id="capital" name="capital" value="" class="input-text" />
            </div>

        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">首都经度：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input onkeyup="change_content(this,10)" id="capital_longitude" name="capital_longitude" value="" class="input-text" />
            </div>
            <label class="form-label col-xs-4 col-sm-2">首都纬度：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input onkeyup="change_content(this,10)" id="capital_latitude" name="capital_latitude" value="" class="input-text" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span
                    class="c-red">*</span>国土面积：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input onkeyup="change_content(this,10)" id="country_area" name="country_area"  class="input-text" />
            </div>
            <label class="form-label col-xs-4 col-sm-2">行政区划：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input id="administrative_division" name="administrative_division" class="input-text" />
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8  col-xs-offset-5 ">

                <button value="${nationinfo.country_code}" type="button" class="btn btn-success radius" onClick="update_nationinfo(this.value)">提交</button>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <button id="close" value="${nationinfo.recoder_id}" onClick="layer_close();" class="btn btn-default radius" type="button"> 关闭</button>
            </div>
        </div>
    </div>
    <%@ include file="/WEB-INF/include/commonjs.jsp"%>
    <script type="text/javascript">//日期控件的设置和初始化
    !function(){
        laydate.skin('molv');//切换皮肤，请查看skins下面皮肤库
    }();

    //日期范围限制
    var start = {
        elem: '#establish_time',
        format: 'YYYY-MM-DD',
        min: '1900-01-01 00:00:00', //设定最小日期
        max: '2099-06-16 00:00:00', //最大日期
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    laydate(start);

    </script>
    <script>
        function update_nationinfo(value){
            var recorder=document.getElementById("close").value;
            var YHZH=parent.parent.document.getElementById("YHZH").innerText;
            if(YHZH.substring(0,3)!='001'&&YHZH.substring(0,3)!=recorder){
                layer.msg("你不能修改不是别人的内容只能查看",{icon:2,time:2000});
                return;
            }
            var nation_z=document.getElementById("nation_z").value;
            var nation_e=document.getElementById("nation_e").value;
            var establish_time=document.getElementById("establish_time").value;
            var capital_longitude=document.getElementById("capital_longitude").value;
            var capital_latitude=document.getElementById("capital_latitude").value;
            var country_area=document.getElementById("country_area").value;
            var capital=document.getElementById("capital").value;
            var administrative_division=document.getElementById("administrative_division").value;
            var continent=document.getElementById("continent").value;
            if(nation_z==null||nation_z==""||country_area==null||country_area==""||continent==null||continent==""){
                layer.msg("带*号的为必填项",{icon:2,time:2000});
                return false;
            }else{
                var cl=capital_longitude.split(".");
                var ca=capital_latitude.split(".");
                if(cl[0].length>3||ca[0].length>2){
                    layer.msg("经度整数部分最多三位纬度整数部分最多两位",{icon:2,time:2000});
                    return;
                }
            }
            layer.confirm("确认提交吗",{btn:['确定','取消']},function(){

                var url="${ctx}/BaseInformation/nationinfo_add.do";
                var parameter={name_z:nation_z,name_e:nation_e,establish_time:establish_time,capital_longitude:capital_longitude,capital_latitude:capital_latitude,
                    country_area:country_area,administrative_division:administrative_division,country_code:value,
                    capital:capital,continent:continent};
                $.post(url,parameter,function(data){
                    if(data=="添加成功"){
                        layer.msg(data,{icon:1,time:2000},function(){
                            parent.location.reload(true);
                        })
                    }else{
                        layer.msg(data,{icon:2,time:2000});
                    }
                })
            })
        }
        function  change_content(t,n) {
            if(t.value.length>n) {
                t.value=t.value.substr(0,n)};t.value=t.value.replace(/[^\d.]/g,'');
        }
    </script>
</article>

</body>

</html>